package com.zjs.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Description Redis的Hash操作
 * @Author zhu_jinsheng[zhu_js@suixingpay.com]
 * @Date 2019/12/5 13:58
 * @Version 1.0
 */
@Component
public class RedisHashUtils {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    public boolean set(String key, Map map) {
        for (Object mapKey : map.keySet()) {
            redisTemplate.opsForHash().put(key, mapKey, map.get(mapKey));
        }
        return true;
    }

    public Object get(String key) {
        return redisTemplate.opsForHash().entries(key);
    }
}
